package cpm.cloud.controller;

import com.test.entities.HandDepartments;
import cpm.cloud.feign.FeignClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author dell
 */
@RestController
@RequestMapping("/feign")
public class FeignController {
    @Autowired
    private FeignClientService feignClientService;

    @RequestMapping("/dept/get/{id}")
    public HandDepartments findById(@PathVariable("id")Long id){
        return feignClientService.findById(id);
    }

    @RequestMapping("/dept/list")
    public List<HandDepartments> findAll(){
        return feignClientService.findAll();
    }

    @RequestMapping("/dept/add")
    public HandDepartments add(HandDepartments departments) {
        return feignClientService.add(departments);
    }

    @DeleteMapping("/dept/del/{id}")
    public void delete(@PathVariable("id") Long id) {
        feignClientService.delete(id);
    }
}
